<template>
	<view class="container">
		<scroll-view class="scrollView" style="height: 100%;" scroll-y="true" @scrolltolower="isDown">
			<view class="invireLog">
				<view class="table">
					<view class="tr">
						<view class="name">邀请用户</view>
						<view class="time">邀请时间</view>
					</view>
					<view class="tr" v-if="list.length>0" v-for="(item,index) in list" :key="index">
						<view class="name">{{item.invite_info.phone}}</view>
						<view class="time">{{item.created_at}}</view>
					</view>
					<view v-else class="kong">
						<img class="img" style="width: 50px;height: 50px;" src="@/static/kong.png" alt="">
						<view>暂无邀请用户~</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import { inviteLog } from '@/api/home.js'
	export default {
		data() {
			return {
				page:1,
				list:[],
				total:0,
			}
		},
		onShow() {
			this.getList()
		},
		methods:{
			isDown(){
				if(this.total > this.list.length){
					this.page += 1
					this.getList()
				}
			},
			getList(){
				inviteLog({page:this.page,pageSize:10}).then(res=>{
					res.data.items.map(item=>{
						let flag = this.list.findIndex(demo=>{return item.id === demo.id})
						if(flag>=0){
							this.list[flag] = item
						}else{
							this.list.push(item)
						}
					})
				})
			}
		}
	}
</script>

<style scoped>
	.scrollView{
		scrollbar-width: none;
	}
	.table{
		border: 1px solid #f2f2f2;
		border-bottom: 0;
	}
	.tr{
		display: flex;
		align-items: center;
		border-bottom: 1px solid #f2f2f2;
	}
	.name{
		width: 40%;
		padding: 6px;
		border-right: 1px solid #f2f2f2;
	}
	.time{
		padding: 6px;
	}
	.container{
		height: calc(100vh - 30px);
		background-color: #fff;
		padding: 10px;
		margin: 10px;
	}
</style>